package top.fkxuexi.blogapi.core.utils.common;

import com.github.pagehelper.PageInfo;
import lombok.Getter;
import lombok.Setter;
import top.fkxuexi.blogapi.modules.auth.entity.SysUser;

import java.util.List;

public class Page<T> {

    /**
     *  数据集
     */
    @Setter@Getter private List<T> rows;

    /**
     *  总的记录条数
     */
    @Setter@Getter private long total;

    /**
     * 当前页码
     */
    @Setter@Getter private int currentIndex;

    /**
     *  页面大小
     */
    @Setter@Getter private int pageSize;

    public static Page page(PageInfo pageInfo){
        Page page = new Page();
        page.setCurrentIndex(pageInfo.getPageNum());
        page.setPageSize(pageInfo.getPages());
        page.setRows(pageInfo.getList());
        page.setTotal(pageInfo.getTotal());
        return page;
    }

}
